
create view [View_ImportInvoices]
as
SELECT        dbo.ImportInvoices.ImportID, dbo.ImportInvoices.InvoceID, dbo.Storages.StoregeName, dbo.ImportInvoices.ImportDate, dbo.Suppliers.SupplierName, 
                         dbo.Employees.LastName + dbo.Employees.FirstName AS FullName, dbo.ImportInvoices.TotalValues
FROM            dbo.ImportInvoices INNER JOIN
                         dbo.Suppliers ON dbo.ImportInvoices.SupplierID = dbo.Suppliers.SupplierID INNER JOIN
                         dbo.Employees ON dbo.ImportInvoices.EmployeeID = dbo.Employees.EmployeeID AND dbo.ImportInvoices.EmployeeID = dbo.Employees.EmployeeID AND 
                         dbo.ImportInvoices.EmployeeID = dbo.Employees.EmployeeID INNER JOIN
                         dbo.Storages ON dbo.Employees.EmployeeID = dbo.Storages.EmployeeID

go

create PROCEDURE ImportInvoices_Report
	(
		@FromDate datetime,
		@ToDate datetime
	)
AS
	select * from View_ImportInvoices where ImportDate between @FromDate and @ToDate
	RETURN
